import 'package:casdon/build_gen/assets.gen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class AIAnimation extends StatefulWidget {
  const AIAnimation({super.key});

  @override
  State<AIAnimation> createState() => _AIAnimationState();
}

class _AIAnimationState extends State<AIAnimation>
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      duration: const Duration(seconds: 3),
      vsync: this,
    )..repeat();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment: Alignment.center,
      children: [
        Assets.images.scannerGrid.image(width: 350.w, height: 350.w),

        Assets.images.icAiText.image(width: 100.w, height: 100.w),

        AnimatedBuilder(
          animation: _controller,
          builder: (_, child) {
            return Transform.rotate(
              angle: _controller.value * 2 * 3.1415926,
              child: child,
            );
          },
          child: Assets.images.icAiCircle.image(width: 100.w, height: 100.w),
        ),

        Assets.images.icAiText.image(width: 100.w, height: 100.w),
      ],
    );
  }
}
